package com.ruibang.glass.purchase.controller;


import com.ruibang.glass.purchase.domain.req.PurchaseSpecialApplicationReq;
import com.ruibang.glass.purchase.entity.PurchaseSpecialApplication;
import com.ruibang.glass.purchase.service.PurchaseSpecialApplicationService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 特采跟踪
 *
 * @author mameng
 */
@Api(tags = "特采跟踪")
@RestController
@RequestMapping("/api/glass/purchase/special/application")
public class PurchaseSpecialApplicationController {


    @Autowired
    private PurchaseSpecialApplicationService purchaseSpecialApplicationService;


    @PostMapping("/list")
    @ApiOperation(value = "特采跟踪列表", response = ResultBody.class)
    public ResultBody queryList(@RequestBody PurchaseSpecialApplicationReq purchaseSpecialApplicationReq) {
        return ResultBody.success(purchaseSpecialApplicationService.getPage(purchaseSpecialApplicationReq));
    }

    @PostMapping("/update")
    @ApiOperation(value = "跟新特采跟踪", response = ResultBody.class)
    public ResultBody updatePurchaseSpecialApplication(@RequestBody PurchaseSpecialApplication purchaseSpecialApplication) {
        purchaseSpecialApplicationService.updateById(purchaseSpecialApplication);
        return ResultBody.success();
    }

    @PostMapping("/add")
    @ApiOperation(value = "新增特采跟踪", response = ResultBody.class)
    public ResultBody addPurchaseSpecialApplication(@RequestBody PurchaseSpecialApplication purchaseSpecialApplication) {
        purchaseSpecialApplicationService.save(purchaseSpecialApplication);
        return ResultBody.success();
    }

    @GetMapping("/add/{id}")
    @ApiOperation(value = "新增特采跟踪", response = ResultBody.class)
    public ResultBody addPurchaseSpecialApplication(@PathVariable("id") String id) {
        return ResultBody.success(purchaseSpecialApplicationService.getById(id));
    }


}
